package com.csu.tingtian.controller;

import com.csu.tingtian.common.CommonResponse;
import com.csu.tingtian.service.ProduceCommentService;
import com.csu.tingtian.vo.ProduceComment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@RestController
@RequestMapping("/producecomment/")
public class ProduceCommentController {
    @Autowired
    private ProduceCommentService produceCommentService;
    @PostMapping("producecomments/producecomment")
    CommonResponse<ProduceComment> userSendCommentToProduce(@RequestBody ProduceComment produceComment){
        return produceCommentService.userSendCommentToProduce(produceComment);
    }
    @DeleteMapping("{itemid}/username/{username}/time/{time}")
    CommonResponse<ProduceComment> userDeleteComment(@PathVariable("itemid") String itemId,@PathVariable("username") String userName,@PathVariable("time") String time){
        return produceCommentService.userDeleteComment(itemId,userName,time);
    }
    @GetMapping("{itemid}/producecomments")
    CommonResponse<List<ProduceComment>> userGetCommentByItemId(@PathVariable("itemid") String itemId){
        return produceCommentService.userGetCommentByItemId(itemId);
    }
    @GetMapping("{farmname}")
    CommonResponse<List<ProduceComment>> getProduceCommentByFarmName(@PathVariable("farmname") String farmName){
        return produceCommentService.getProduceCommentByFarmName(farmName);
    }
}
